package com.architecture.util.money;

import java.text.NumberFormat;

import com.architecture.util.object.ObjectUtility;
import com.architecture.util.string.StringUtility;


/**
 * <p>This class has utilities methods for be used with Money.</p>
 * @author JR
 * @version 1.0
 * @category Money Utilities
 */
public final class MoneyUtility {
	
	public static final NumberFormat numberFormatInstance = NumberFormat.getCurrencyInstance();
	
	/**
	 * private constructor of <code>MoneyUtility</code>.
	 */
	private MoneyUtility() {
		super();
	}
	
	/**
	 * <p>Format a number using the default locale</p>
	 * @param number
	 * @return String
	 */
	public static String toMoney(final Double number){
		if(ObjectUtility.isNotRef(number)){
			return numberFormatInstance.format(number);	
		}else{
			return StringUtility.EMPTY_STRING;
		}
	}
	
	/**
	 * <p>Format a number using the default locale</p>
	 * @param number
	 * @return String
	 */
	public static String toMoney(final Long number){
		if(ObjectUtility.isNotRef(number)){
			return numberFormatInstance.format(number);	
		}else{
			return StringUtility.EMPTY_STRING;
		}
	}
	
}
